// ObjectController.cs created with MonoDevelop
// User: kpr at 16:16 26.11.2007
//
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
//
// created on 26.11.2007 at 16:16

using System;
using System.Collections.Generic;

namespace Builder
{
	public class ParseController : SingletonManager<ParseController>
	{
		List<string> globVars = new List<string>();
		List<Object> objects = new List<Object>();
		public Object CreateObject(string name)
		{
			Object o = new Object();
			objects.Add(o);
			o.Name = name;
			o.StartString += "public class "+name+" : ObjParent\n{";
			o.StartString += "public "+name+"(int x, int y, Room lev) : base(x, y, lev)\n{";
			return o;
		}
		public string GetOutput()
		{
			string ret = "";
			foreach(Object o in objects)
			{
				ret += o.GetOutput();
			}
			return ret;
		}
		/// <Summary>
		/// Parses a specific code for an Object in an event
		/// </Summary>
		public void ParseCode(Object o, string eid, string code)
		{
			o.Events += GMLParser.ParseCode(o,"ev"+eid, code);
		}
	}
	public class Object
	{
		public string StartString = "";
		public string Name;
		public string Events = "";
		public List<string> Vars = new List<string>();
		
		public string GetOutput()
		{
			return StartString+"\n"+GetVars()+"\n"+Events+"\n}\n";
		}
		public string GetVars()
		{
			string obj_vars = "";
			foreach(string var in Vars)
			{
				obj_vars+= "public Variable var_"+var+";\n";
			}
			return obj_vars;
		}
	}
}